import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import java.util.Scanner;
public class Merhod {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要计算的数字");
        int right=scanner.nextInt();
        sum(right);
        System.out.println(sum(right));
    }
    public static int sum(int n){
        if(n<10){
            return n;
        }else{
            return n%10+sum(n/10);
        }
    }
        /*
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要分解的数字");
        int right=scanner.nextInt();
        print(right);
    }
    public static void print(int num){
        if(num>9){
            print(num/10);
        }
        System.out.print (num%10+" ");


        if(num>9){
            print(num/10);//123{
                printf(num/10)//12
            }
            System.out.println(num%10);

        }
        System.out.println(num%10);
    }


        /*
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要计算的数字");
        int ret=scanner.nextInt();
        ret=factor(ret);
        System.out.println(ret);
        }
        public static int factor(int n) {
            if (n == 1) {
                return 1;
            } else {
                return n*factor(n-1);
            }
        }
        /*
        System.out.println(add(1,2));
        System.out.println(add(1,2,1.5));
    }
    public static int add(int x,int y){
        return x+y;
    }
    public static double add(int x,int y,double z){
        return x+y+z;
    }
        /*
        int a=10;
        int b=100;
        swap(a,b);
        System.out.println("a="+a+" "+"b="+b);
    }
    public static void swap(int x,int y){
        int tmp=x;
        x=y;
        y=tmp;
    }
        /*
        System.out.println(getSum(10));
        System.out.println(getSum(100));
    }
    public static int getSum(int n){
        return (1+n)*n/2;
    }
        /*
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字");
        int right = scanner.nextInt();
        System.out.println(fac(right));
    }
    public static int fac(int right){
        int num=0;
        for(int i=1;i<=right;i++){
            int sum=1;
            for(int j=1;j<=i;j++){
                sum*=j;
            }
            num+=sum;
        }
        return num;
    }
        /*
        fac(right);
        int sum=0;
        for(int i=1;i<=right;i++){
            sum+=fac(i);
        }
        System.out.println(sum);
    }
    public static int fac(int n){
        int result=1;
        for(int i=1;i<=n;i++){
            result*=i;
        }
        return result;
    }
        /*
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入第一个数字");
        int x=scanner.nextInt();
        System.out.println("请输入第二个数字");
        int y=scanner.nextInt();
        System.out.println(add(x,y));

        System.out.println("请输入第三个数字");
        int z=scanner.nextInt();
        System.out.println(add(add(x,y),z));
    }
    public static int add(int x,int y){
        return x+y;
    }
        /*
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入第一个数字");
        int x=scanner.nextInt();
        System.out.println("请输入第二个数字");
        int y=scanner.nextInt();
        System.out.println(add(x,y));
    }
    public static int add(int x,int y){
        return x+y;
    }
        /*
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年份");
        int year = scanner.nextInt();
        isLeapYear(year);
        System.out.println(isLeapYear(year));
    }

    public static boolean isLeapYear(int year) {
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            return true;
        } else {
            return false;
        }
    }
    */
}
